﻿using System;
using System.Collections.Generic;
using System.Text;
using VietKinsNutrition.Data;
using DevExpress.XtraEditors;
using System.Windows.Forms;
using System.Data;

namespace VietKinsNutrition.Bussiness
{
    public class ClsTblPhieutienanBLL : ClsBindingBLL
    {
        ////ClsConnection ClsCnn = new ClsConnection();
        ClsTblPhieutienanDAL ClsTblPhieutienandal = new ClsTblPhieutienanDAL();
        // SelectAllBySobienlai
        public void Delte_TblPhieutienan_DelByNamhocId(int NamhocId)
        {
            this.ClsTblPhieutienandal.Delte_TblPhieutienan_DelByNamhocId(NamhocId);
        }
        public bool CheckBienlai(int NamhocId, int ThanghocId, int LophocId, int NamtrehocId, string Sobienlai)
        {
            return ClsTblPhieutienandal.CheckBienlai(NamhocId, ThanghocId, LophocId, NamtrehocId, Sobienlai);
        }
        public void Bind_LophocCbo(System.Windows.Forms.ComboBox LophocIdCombo, int NamhocID)
        {
            ClsTblDm_NamhocBLL ClsTblDm_Namhocbll = new ClsTblDm_NamhocBLL();
            DataTable dt = new DataTable();
            DataTable Tbl = new DataTable();

            ClsTblLophocDAL ClsTblLophocdal = new ClsTblLophocDAL();
            dt = ClsTblLophocdal.GetAll(NamhocID);

            Tbl = dt.Clone();
            Tbl.Rows.Add(0, -1, "Tất cả");
            foreach (DataRow Rw in dt.Rows)
            {
                Tbl.Rows.Add(Rw["STT"], Rw["Id"], Rw["Tenlop"]);
            }
            LophocIdCombo.DataSource = Tbl;
            LophocIdCombo.ValueMember = "Id";
            LophocIdCombo.DisplayMember = "Tenlop";
        }
        public void Bind_GridViewFind(DataGridView Grid, string Tenhocsinh, int ThanghocId, string Tenlop, string Gioitinh, int NamhocID)
        {
            Grid.DataSource = this.ClsTblPhieutienandal.BingSoure_Find(Tenhocsinh, NamhocID, ThanghocId, Tenlop, Gioitinh);
        }
        public void Bind_GridView(DataGridView Grid, int ThanghocId, int NamhocID)
        {
            Grid.DataSource = this.ClsTblPhieutienandal.SelectAll(NamhocID, ThanghocId);
        }
        public DataTable SelectAllBySobienlai(string Sobienlai)
        {
            return ClsTblPhieutienandal.SelectAllBySobienlai(Sobienlai).Tables[0];
        }
        public void Insert(string Sobienlai, int NamtrehocId, DateTime Ngaymua, int ThanghocId, int Tongsophieumua, int Tongsophieudoi, float Dongia, string Ghichu)
        {
            ClsTblPhieutienandal.Insert(Sobienlai, NamtrehocId, Ngaymua, ThanghocId, Tongsophieumua, Tongsophieudoi, Dongia, Ghichu);
        }
        public void Delte(int Id)
        {
            ClsTblPhieutienandal.Delte(Id);
        }
        public void Edit(int Id, string Sobienlai, int NamtrehocId, DateTime Ngaymua, int ThanghocId, int Tongsophieumua, int Tongsophieudoi, float Dongia, string Ghichu)
        {
            ClsTblPhieutienandal.Edit(Id, Sobienlai, NamtrehocId, Ngaymua, ThanghocId, Tongsophieumua, Tongsophieudoi, Dongia, Ghichu);
        }
        public static DataTable GetAllByLop(int LophocID, int ThanghocID)
        {
            return ClsTblPhieutienanDAL.GetAllByLop(LophocID, ThanghocID);
        }
        public DataTable GetTongsobuaan(DateTime Ngaythang, int NamtrehocId)
        {
            return ClsTblPhieutienandal.GetTongsobuaan(Ngaythang, NamtrehocId);
        }
        public static DataTable CountfromBaoanchitiet(int LophocID, int ThanghocID)
        {
            object[] value = { LophocID, ThanghocID };
            return ClsTblPhieutienanDAL.GetAllByLop(value);
        }
    }
}
